package com.et114.modules.suspect.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.et114.core.action.BaseDispatchAction;
import com.et114.modules.org.services.UserManager;
import com.et114.modules.org.utility.SessionUserInfo;
import com.et114.modules.org.vo.UserVo;
import com.et114.modules.suspect.form.SuspectForm;
import com.et114.modules.suspect.service.IMng_SuspectService;
import com.et114.modules.suspect.service.Mng_SuspectServiceImp;
import com.et114.modules.suspect.vo.SusPectVO;

/**
 * 投诉管理
 * 
 * @author zhiweip
 * @version 1.0
 * @created 02-十二月-2010 22:00:29
 */
public class Mng_SuspectAction extends BaseDispatchAction {
	
	public IMng_SuspectService	m_IMng_SuspectService	= ( Mng_SuspectServiceImp ) getBean ( "m_IMng_SuspectService" );
	
	public Mng_SuspectAction ( ) {
		
	}
	
	public void finalize ( ) throws Throwable {
		
	}
	
	@ Override
	public ActionForward unspecified ( ActionMapping mapping , ActionForm form ,
			HttpServletRequest request , HttpServletResponse response )
			throws Exception {
		UserManager userManager = ( UserManager ) getBean ( "userManager" );
		UserVo user = new UserVo ( );
		user.setPageSize ( 10000 );
		request.setAttribute ( "EMPLYS" , ((com.et114.modules.cust.dao.Mng_CustDaoImp)getBean("mng_CustDao")).query_AllEmpList(null) );
		SuspectForm sform = ( SuspectForm ) form;
		return mapping.findForward ( "queryDataList" );
	}
	
	/**
	 * 查询
	 */
	public ActionForward queryList ( ActionMapping mapping , ActionForm form ,
			HttpServletRequest request , HttpServletResponse response )
			throws Exception {
		SuspectForm sform = ( SuspectForm ) form;
		SusPectVO sus = sform.getSus ( );
		UserManager userManager = ( UserManager ) getBean ( "userManager" );
		UserVo user = new UserVo ( );
		user.setPageSize ( 10000 );
		request.setAttribute ( "EMPLYS" , ((com.et114.modules.cust.dao.Mng_CustDaoImp)getBean("mng_CustDao")).query_AllEmpList(null) );
		
		sus.setPageNum ( sform.getPageNum ( ) );
		sus.setPageSize ( sform.getPageSize ( ) );
		request.setAttribute ( "sus" , sus );
		request.setAttribute ( "DataList" , m_IMng_SuspectService
				.queryDataList ( sus ) );
		return mapping.findForward ( "queryDataList" );
	}
	
	public ActionForward toModify ( ActionMapping mapping , ActionForm form ,
			HttpServletRequest request , HttpServletResponse response )
			throws Exception {
		UserManager userManager = ( UserManager ) getBean ( "userManager" );
		UserVo user = new UserVo ( );
		user.setPageSize ( 10000 );
		request.setAttribute ( "EMPLYS" , ((com.et114.modules.cust.dao.Mng_CustDaoImp)getBean("mng_CustDao")).query_AllEmpList(null) );
		SuspectForm sform = ( SuspectForm ) form;
		SusPectVO sus = sform.getSus ( );
		String spid = request.getParameter ( "spid" );
		if ( spid != null ) { 
			sus.setSpid ( new Integer ( spid ) );
			request.setAttribute ( "SusInfo" , m_IMng_SuspectService
					.loadSuspect ( sus ) );
		}
		
		return mapping.findForward ( "toUpdate" );
	}
	
	
	public ActionForward update ( ActionMapping mapping , ActionForm form ,
			HttpServletRequest request , HttpServletResponse response )
			throws Exception {
		SuspectForm sform = ( SuspectForm ) form;
		SusPectVO sus = sform.getSus ( );
		SessionUserInfo sessionuserinfo = getCurrentUser ( request );
		sus.setCrtUser ( sessionuserinfo.getUserId ( ) );
		
		m_IMng_SuspectService.updateSuspect ( sus );
		return mapping.findForward ( "queryDataList" );
	}
	public ActionForward toTrack ( ActionMapping mapping , ActionForm form ,
			HttpServletRequest request , HttpServletResponse response )
			throws Exception {
		UserManager userManager = ( UserManager ) getBean ( "userManager" );
		UserVo user = new UserVo ( );
		user.setPageSize ( 10000 );
		request.setAttribute ( "EMPLYS" , ((com.et114.modules.cust.dao.Mng_CustDaoImp)getBean("mng_CustDao")).query_AllEmpList(null) );
		SuspectForm sform = ( SuspectForm ) form;
		SusPectVO sus = sform.getSus ( );
		String spid = request.getParameter ( "spid" ); 
		sus.setSpid ( new Integer ( spid ) );
		request.setAttribute ( "SusInfo" , m_IMng_SuspectService
				.loadSuspect ( sus ) );
		
		request.setAttribute ( "SusLog" , m_IMng_SuspectService
				.queryDetailList ( sus ) );
		
		return mapping.findForward ( "toTrack" );
	}
	
	
	public ActionForward view ( ActionMapping mapping , ActionForm form ,
			HttpServletRequest request , HttpServletResponse response )
			throws Exception {
		SuspectForm sform = ( SuspectForm ) form;
		SusPectVO sus = sform.getSus ( );
		String spid = request.getParameter ( "spid" );
		sus.setSpid ( new Integer ( spid ) );
		request.setAttribute ( "SusInfo" , m_IMng_SuspectService
				.loadSuspect ( sus ) );
		
		request.setAttribute ( "SusLog" , m_IMng_SuspectService
				.queryDetailList ( sus ) );
		
		return mapping.findForward ( "view" );
	}
	
}